package com.jvmmonitor.model;

import java.util.ArrayList;
import java.util.List;

/**
 * JVM参数优化建议模型
 */
public class JvmAdvice {
    // 建议类型
    public enum AdviceType {
        HEAP_SIZE,          // 堆内存大小建议
        GC_ALGORITHM,       // GC算法建议
        LARGE_OBJECT,       // 大对象处理建议
        METASPACE,          // 元空间建议
        DIRECT_MEMORY,      // 直接内存建议
        CODE_CACHE,         // 代码缓存建议
        OTHER               // 其他建议
    }
    
    // 建议级别
    public enum AdviceLevel {
        INFO,               // 信息性建议
        WARNING,            // 警告性建议
        CRITICAL            // 关键性建议
    }
    
    // 建议项内部类
    public static class AdviceItem {
        private AdviceType type;
        private AdviceLevel level;
        private String description;
        private String suggestion;
        private String reason;
        
        public AdviceItem(AdviceType type, AdviceLevel level, String description, String suggestion, String reason) {
            this.type = type;
            this.level = level;
            this.description = description;
            this.suggestion = suggestion;
            this.reason = reason;
        }
        
        // Getters
        public AdviceType getType() {
            return type;
        }
        
        public AdviceLevel getLevel() {
            return level;
        }
        
        public String getDescription() {
            return description;
        }
        
        public String getSuggestion() {
            return suggestion;
        }
        
        public String getReason() {
            return reason;
        }
        
        @Override
        public String toString() {
            return "AdviceItem{" +
                    "type=" + type +
                    ", level=" + level +
                    ", description='" + description + '\'' +
                    ", suggestion='" + suggestion + '\'' +
                    ", reason='" + reason + '\'' +
                    '}';
        }
    }
    
    // 建议列表
    private List<AdviceItem> adviceItems;
    
    // 生成时间
    private long timestamp;
    
    public JvmAdvice() {
        this.adviceItems = new ArrayList<>();
        this.timestamp = System.currentTimeMillis();
    }
    
    // 添加建议项
    public void addAdviceItem(AdviceItem adviceItem) {
        this.adviceItems.add(adviceItem);
    }
    
    // Getters and Setters
    public List<AdviceItem> getAdviceItems() {
        return adviceItems;
    }
    
    public void setAdviceItems(List<AdviceItem> adviceItems) {
        this.adviceItems = adviceItems;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    @Override
    public String toString() {
        return "JvmAdvice{" +
                "adviceItems=" + adviceItems +
                ", timestamp=" + timestamp +
                '}';
    }
}